<template>
  <view class="mid-main">
    <no-login-mid @setShow="setNowShow" v-if="show == 100"></no-login-mid>
    <view v-else>
      <report-repair @submitSuccess="submitSuccess" v-if="add == 0"></report-repair>
      <save-truck v-else-if="add == 1"></save-truck>
      <view v-else-if="show == 3">功能积极开发中</view>
    </view>
    
  </view>
</template>

<script>
  import noLoginMid from '@/pages/mid/no_login_mid'
  import reportRepair from '@/pages/mid/main/report_repair'
  import saveTruck from '@/pages/mid/main/save_truck'
  export default {
    props:{
      add:Number
    },
    data(){
      return {
        show:0,
      }
    },
    created() {
      this.load()
    },
    onHide() {
    },
    mounted() {
      
    },
    components:{
      noLoginMid,
      reportRepair,
      saveTruck
    },
    methods:{
      load:function() {
        if(uni.getStorageSync("token").length == 0) {
          this.show = 100;
        }else {
          this.show = this.add;
          console.log(this.add)
        }
      },
      setNowShow:function(user) {
        this.show = 1;
        this.$emit('loginSuccess',user);
        this.show = 0;
      },
      submitSuccess:function(key) {
        this.$emit("submitSuccess",key);
      }
    }
  }
</script>

<style lang="css" scoped>

</style>